﻿<div class="panel-body">

    <img id="waiting" src="../Media/waiting.gif" ng-show="variablegif.modo == 'wait'" style="position:absolute;z-index:100;top:30%;right:50%;" />

    <form class="form-horizontal">
        <fieldset>
            <legend>Detalle EndPoint</legend>

            <div class="form-group">
                <label for="inputId" class="col-lg-2 control-label">ID</label>
                <div class="col-lg-10">
                    <input type="text" class="form-control" id="inputId" ng-model="endpoint.ID" disabled>
                </div>
            </div>
            <div class="form-group">
                <label for="inputNombre" class="col-lg-2 control-label">Nombre</label>
                <div class="col-lg-10">
                    <input type="text" class="form-control" id="inputNombre" ng-model="endpoint.Nombre" ng-disabled="vars.modo == 'detail'">
                </div>
            </div>
            <div class="form-group">
                <label for="inputRuta" class="col-lg-2 control-label">Ruta</label>
                <div class="col-lg-10">
                    <input type="text" class="form-control" id="inputRuta" ng-model="endpoint.Ruta" ng-disabled="vars.modo == 'detail'">
                </div>
            </div>
            <div class="form-group">
                <label for="selectTipo" class="col-lg-2 control-label">Tipo</label>
                <div class="col-lg-10">
                    <select id="selectTipo" ng-model="endpoint.TipoID" ng-options="tipo.ID as tipo.Nombre for tipo in tipos" class="form-control" ng-disabled="vars.modo == 'detail'"></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">Variables</label>
                <div class="col-lg-10" style="margin-top:5px;">
                    <input type="button" class="btn btn-info btn-sm" style="margin-right:10px;" ng-repeat="variable in variables" value="{{variable.Nombre}}" id="{{variable.ID}}" />
                    <input data-toggle="modal" data-target="#añadirDetalleModal" type="button" class="btn btn-success btn-sm" value="+ Añadir" />
                </div>
            </div>

            <div class="form-group" style="float:right;margin-top:2%;margin-right:3%;">
                <a href="" ng-click="guardar()" ng-show="vars.modo == 'update'"><input type="button" class="btn btn-success" value="Guardar" /></a>
                <a href="" ng-click="update()" ng-show="vars.modo == 'detail'"><input type="button" class="btn btn-success" value="Editar" /></a>
                <button data-toggle="modal" data-target="#eliminarModal" type="button" ng-show="vars.modo == 'detail'" class="btn btn-warning">Eliminar</button>
                <a href="#/" ng-show="vars.modo == 'detail'"><input type="button" class="btn btn-danger" value="Volver" /></a>
                <a href="" ng-click="detail()" ng-show="vars.modo == 'update'"><input type="button" class="btn btn-default" value="Cancelar" /></a>
            </div>
        </fieldset>
        <fieldset>
            <div class="form-group" style="float:right;margin-right:50%;">
                <button type="button" class="btn btn-lg btn-success" ng-disabled="vars.editarDetalle" ng-click="ejecutar()">EJECUTAR</button>
            </div>
        </fieldset>
    </form>

    <div>
        <fieldset>
            <legend>Ejecuciones</legend>
        </fieldset>

        <table class="table table-striped table-hover" style="margin-top:20px;">
            <thead>
                <tr>
                    <td><a href="" ng-click="sortField = 'ID'; reverse = !reverse">ID</a></td>
                    <td><a href="" ng-click="sortField = 'FechaEjecucion'; reverse = !reverse">Fecha Ejecución</a></td>
                    <td><a href="" ng-click="sortField = 'Tamano'; reverse = !reverse">Tamaño (bytes)</a></td>
                    <td><a href="" ng-click="sortField = 'RutaDescarga'; reverse = !reverse">Ruta Descarga</a></td>
                    <td></td>
                </tr>
            </thead>
            <tbody>
                <tr ng-repeat="ejecucion in ejecuciones | filter:query | orderBy:sortField:reverse">
                    <th scope="row">{{ejecucion.ID}}</th>
                    <td>{{ejecucion.FechaEjecucion}}</td>
                    <td>{{ejecucion.Tamano}}</td>
                    <td>{{ejecucion.RutaDescarga}}</td>
                    <td><a href="#/detalleejecucion/{{ejecucion.ID}}">Detalles</a></td>
                </tr>
            </tbody>
        </table>
    </div>

    <div class="modal fade" id="eliminarModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">Eliminar EndPoint</h4>
                </div>
                <div class="modal-body">
                    <h6>Se eliminará el EndPoint: {{endpoint.Nombre}}</h6><br />
                    <h6>¿Está seguro?</h6>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-success" data-ng-click="eliminar()">Eliminar</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade " id="añadirDetalleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content ">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">Añadir variable</h4>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label class="control-label col-lg-4">ID </label>
                        <div class="col-lg-8">
                            <input type="text" class="form-control " ng-model="variable.ID" disabled />
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">Variable</label>
                        <div class="col-lg-8">
                            <input type="text" class="form-control" ng-model="variable.Nombre" />
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-success" data-dismiss="modal" data-ng-click="anadir()">Añadir</button>
                    <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
                </div>
            </div>
        </div>
    </div>
</div>